All Questions
Tagged with wp-enqueue-scriptfunctions
105 questions
0votes
1answer
54views
Wordpress generating Undefined Variable warning
Please help! I updated my php to 8.0 and my WordPress install to the current version (6.7.1), and now get the following warning messages on my site: Warning: Undefined variable $post in /home/...
2votes
1answer
233views
wp_script_add_data not working
We are trying to add "async" to our script using this code. However this is not added by wordpress. Not sure why it's not doing anything. function wp_mk_scripts() { if ( is_page(26202) )...
3votes
1answer
878views
Loading newest dependency javascript module file in functions.php
Continuing from this question: I have scripts enqueued in functions.php file so scripts load only on certain pages (I cut most of them in code below): add_action( 'template_redirect', 'plugin_is_page' ...
4votes
1answer
337views
Auto updating JavaScript dependancy in functions.php
I'm enqueuing scripts with dependency in functions.php file like: wp_enqueue_script('ads', get_template_directory_uri() . '/js/ads.js', array( ), '1.6', true); wp_enqueue_script('banners', ...
0votes
3answers
1kviews
wp_enqueue_script doesn't load JS in plugin
I wrote the following code in a standalone plugin, but it doesn't work Please guide me how to modify the code, so the JS file is loaded. <?php /* Plugin Name: Copy post */ class CopyPostApi{ ...
0votes
0answers
483views
Warning: filemtime(): stat failed for wp_
Currently getting this warning in php. Warning: filemtime(): stat failed for https://madeupurl.com/wp-content/themes/madeup/assets/js/scripts.js in /var/www/wp-content/themes/madeup/functions.php on ...
1vote
1answer
570views
Enqueue scripts not working with if is page conditional tag in functions.php
Is this even the correct way of including scripts on a specific page? function insert_mapsvg_scripts() { wp_enqueue_style( 'mapsvg_css', site_url('/mapsvg/css/mapsvg.css') ); wp_enqueue_style( '...
0votes
0answers
271views
Advanced method to control cache of enqueued style/script
I have a WordPress website with medium-level traffic, ~10,000 unique visitors a day. Arround 30% of my daily visitors are recurrent. I constantly make some UI improvements: colors, font-size, ...
2votes
3answers
2kviews
Enqueue script o style only if a template part is loaded
I have registered some styles and scripts that should be loaded if a template part is loaded in a template file. For ex: in home.php <?php get_template_part( 'template-parts/external_links'); ?> ...
0votes
1answer
119views
How to load a css file depending on the current role
I have created a custom role (b2b) and I am trying to load a css file while the 'b2b' role is logged in or the administrator. I have tried the code below and I can't get it to work. Any help or ...
0votes
1answer
97views
Add default value from selection <select>
working on my first plugin where a user can select an option from a dropdown and this selection gets saved in a code that gets written into the footer. That works, but the problem is, my default ...
0votes
1answer
316views
localize_script but data changes dependent on product ID
I currently have this code in my functions.php file. $dataToBePassed = array(); add_action( 'wp_enqueue_scripts', function() { $handle = 'three-d-scripts'; $src = ...
0votes
2answers
482views
WordPress wp_dequeue_script remove all other scripts
I want to override function in child theme to remove specific scripts, which is defined inside a class in parent theme. Parent theme functions.php class Theme_Assets extends Theme_Base { /** ...
0votes
1answer
690views
Add custom css file after plugin css with Wordpress Child Theme functions.php
I am trying to enque a css file thorugh my child themes functions.php after a specific plugin css file with the handle openpos.bill.bootstrap. Unfortunately the current code does not load anything. ...
0votes
1answer
617views
How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
I’ve created a plugin for my child theme, in which custom functions are stored. Additionally, within the plugin, I'm also enqueueing stylesheets and .js which control the output of two templates, for ...